/*
* $Id: ListBoxStateParser.h 92 2010-05-26 00:57:49Z volok-aleksej@yandex.ru $
*
* Copyright 2008-2009 by Volokitin Alexey
* All rights reserved
*
*/
#ifndef _LIST_BOX_STATE_PARSER_H_
#define _LIST_BOX_STATE_PARSER_H_

#define _DELETE		_T("delete")
#define _ADD		_T("add")
#define _EXIST		_T("exist")
#define _CHANGE _T("change")

struct Col{
	std::tstring m_strName;
	int m_nId;
	std::tstring m_strOperation;
	Col(const std::tstring& strName, int nId, const std::tstring& strOperation)
		: m_strName(strName), m_nId(nId), m_strOperation(strOperation){}
	bool operator == (const std::tstring& strName){
		return m_strName == strName;
	}
	bool operator == (const Col& col){
		return col.m_strName == m_strName;
	}
};

class CListBoxStateParser
{
	std::tstring m_strSel;
	std::vector<Col> m_aDelCols;
	std::vector<Col> m_aAddCols;
	std::vector<Col> m_aExistCols;
	void ParseElement(const std::tstring& strElement);
	void ParseState(const std::tstring& strState);
public:
	CListBoxStateParser(const std::tstring& strState);
	std::tstring GetCurSel();
	std::vector<Col> GetAddColumn();
	std::vector<Col> GetDeleteColumn();
	std::vector<Col> GetExistColumn();
	std::tstring GetState();
	void SetCurSel(const std::tstring& strState);
	void AddChange(const std::tstring& strName, int strType, const std::tstring& strOperation);
	void SaveChange();
	std::vector<Col> GetAllColumns();
};

#endif /*_LIST_BOX_STATE_PARSER_H_*/